package com.hmdp.controller;


import com.hmdp.dto.Result;
import com.hmdp.service.IFollowService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 虎哥
 * @since 2021-12-22
 */
@RestController
@RequestMapping("/follow")
public class FollowController {
    @Resource
    private IFollowService followService;

    /**
     * 查询是否关注
     * @param id
     * @return
     */
    @GetMapping("or/not/{id}")
    public Result isFollow(@PathVariable("id") Long id){
        return followService.isFollow(id);
    }

    /**
     * 关注与取消关注
     */
    @PutMapping("{id}/{flag}")
    public Result doFollow(@PathVariable("id") Long id,@PathVariable("flag") Boolean flag){
        return followService.doFollow(id,flag);

    }

    /**
     * 查询共同关注
     */
    @GetMapping("common/{id}")
    public Result getFollowCommon(@PathVariable("id") String id){
        return followService.getFollowCommon(id);
    }
}
